package api

import (
	"context"
	"net/http"

	"github.com/gin-gonic/gin"
)

type Server struct {
	Router *gin.Engine
	Port   string
	server *http.Server
}

func (s *Server) Start() error {
	s.server = &http.Server{
		Addr:    s.Port,
		Handler: s.Router,
	}

	return s.server.ListenAndServe()
}

func (s *Server) Stop(ctx context.Context) error {
	if s.server != nil {
		return s.server.Shutdown(ctx)
	}
	return nil
}
